package com.adv.netWork01.weatherServer;

import java.io.*;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;

public class WeatherClient {

	public static void main(String[] args) throws Exception {
		Scanner input = new Scanner(System.in);
		Socket s = new Socket("localhost", 9999);
		System.out.println("-----------客户端-------------");
		InputStream in = s.getInputStream();
		OutputStream out = s.getOutputStream();
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		PrintWriter pw = new PrintWriter(out);
		String str;
		while (true) {
			// System.out.println("链接服务器成功！");
			String reply = br.readLine();
			System.out.println("服务器说:" + reply);
			System.out.print("请输入:");
			str = input.next();
			pw.println(str);
			pw.flush();
			if (str.equalsIgnoreCase("quit")) {
				break;
			}
		}
		s.close();
		System.out.println("客户端关闭！");

	}

}
